#include "rtc_learn.h"
char stime[9];
//在CUBEMX开启低速外部时钟，配置RTC时间，开启ALARM定时中断，相当于闹钟
//在RTC_Alarm_IRQHandler中断处理函数执行相应任务
//RTC_DateTypeDef sdatestructure;
//RTC_TimeTypeDef stimestructure;
//获取实时时间
//    HAL_RTC_GetTime(&hrtc, &stimestructure, RTC_FORMAT_BIN);
//    /* Get the RTC current Date */
//获取实时日期
//    HAL_RTC_GetDate(&hrtc, &sdatestructure, RTC_FORMAT_BIN);
//    /* Display date Format : yy/mm/dd */
//    printf("%02d/%02d/%02d\r\n",2000 + sdatestructure.Year, sdatestructure.Month, sdatestructure.Date);
//    /* Display time Format : hh:mm:ss */
//    printf("%02d:%02d:%02d\r\n",stimestructure.Hours, stimestructure.Minutes, stimestructure.Seconds);
//将整型时间转化为字符型
void time (uint8_t hour,uint8_t minute, uint8_t seconds)
{
	uint8_t num[3];
	num[0] = hour; num[1] = minute; num[2] = seconds;
	for(int i=0,j=0;i<2;i++,j+=3)
	{
		stime[j] = (num[i]/10) + '0';
		stime[j+1] = (num[i]%10) + '0';
		stime[j+2] = ':';
	}
	stime[6] = (num[2]/10) + '0'; stime[7] = (num[2]%10) + '0';
	stime[8] = '\0';

}
